grstyle init
grstyle set plain
grstyle set legend 6, nobox
grstyle set color viridis, n(8) range(0.2,0.8)

set seed 119922

* set working directory: TO BE ADJUSTED
cd ""

use "dataset.dta", clear

svyset _n [pweight=inv_prob_allland]

** Figures: Forest Use Restrictions

quietly tabplot treat for_restrictions [aweight=inv_prob_allland], percent(treat) showval(offset(0.05) format(%2.1f)) xtitle("Forest restriction index", margin("medium")) ytitle("") subtitle("") plotregion(margin(b=2.5)) name(fig1, replace) title("A: Forest Owners", pos(11) yoffset(2) xoffset(-15) margin(medsmall)) xlabel(,format(%9.2f)) xasis barwidth(0.07) nodraw
quietly tabplot treat for_restrictions_nfo [aweight=inv_prob_allland], percent(treat) showval(offset(0.05) format(%2.1f)) xtitle("Forest restriction index", margin("medium")) ytitle("") subtitle("") plotregion(margin(b=2.5)) name(fig2, replace) title("B: Non-Forest Owners", pos(11) yoffset(2) xoffset(-15) margin(medsmall)) xlabel(,format(%9.2f)) xasis barwidth(0.07) nodraw
graph combine fig1 fig2, col(2) ysize(10) xsize(14) 
graph export  "SI/Figures/bar_forest_restrict.pdf", name(Graph) replace

quietly gr box for_restrictions [aweight=inv_prob_allland], over(treat) ytitle("Forest restriction index") title("A: Forest Owners", pos(11) yoffset(2) xoffset(-5) margin(medsmall)) name(fig1, replace) nodraw
quietly gr box for_restrictions_nfo [aweight=inv_prob_allland], over(treat) ytitle("Forest restriction index") title("B: Non-Forest Owners", pos(11) yoffset(2) xoffset(-5) margin(medsmall)) name(fig2, replace) nodraw
graph combine fig1 fig2, col(2) ysize(10) xsize(14) 
graph export  "SI/Figures/box_forest_restrict.pdf", name(Graph) replace


** Balancing Tables
global covariates hh_head dem_age dem_female dem_sch_year dem_adult_no dem_child_no dem_hh_size dem_hh_female dem_hh_sch_year ass_ses_index land_ownership land_pieces land_area_total land_forest_yn land_forestarea_total land_forestarea_rel land_forest_mature_yn land_forestarea_mature_total land_forestarea_mature_rel land_woodlot_yn land_woodlot_area_total

quietly iebaltab $covariates [pweight=inv_prob_allland], grpvar(treat) total ftest fmissok rowvarlabels stdev texcolwidth("3cm") savetex("SI/Tables/balance_treat_PFO_pweights.tex") replace

global base_covariates base_hhead_age base_hhead_educ base_hh_has_land base_land_area base_forest_area base_any_tree_cut base_rent base_disputewith3 base_base_fcover_act base_ihs_tim_price base_ihs_food_cons base_ihs_nofood_cons base_ass_ses_index

quietly iebaltab $base_covariates [pweight=inv_prob_allland], grpvar(treat) total ftest fmissok rowvarlabels stdev texcolwidth("3cm") savetex("SI/Tables/balance_base_treat_PFO_pweights.tex") replace


** Regressions from Paper

global controls i.base_subcounty strat_base_num_PFOs_vil strat_base_inc_pc_vil strat_base_dist_road_vil strat_base_l1_area_vil

eststo tobit_for_rest_for_own: quietly tobit for_restrictions i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo: quietly tobit for_restrictions_nfo i.treat i.enumerator $controls  [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)


eststo tobit_pnorm_pfo: quietly tobit index_personalnorm i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_pfo: quietly tobit index_socialnorm i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

quietly probit soc_type_spiteful i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_spiteful_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly probit soc_type_generous i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_generous_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly probit soc_type_egalitarian i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_egali_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

** Robustness Checks

** w/o enumerator FE

*forest use restrictions

eststo tobit_for_rest_for_own2: quietly tobit for_restrictions i.treat  $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo2: quietly tobit for_restrictions_nfo i.treat  $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

* personal and social norms

eststo tobit_pnorm_pfo2: quietly tobit index_personalnorm i.treat $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_pfo2: quietly tobit index_socialnorm i.treat  $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

*social preferences

quietly probit soc_type_spiteful i.treat $controls  [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_spiteful2_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly probit soc_type_generous i.treat $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_generous2_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly probit soc_type_egalitarian i.treat $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_egali2_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi


* Robstness check with unbalanced baseline characterstics

*forest use restrictions

eststo tobit_for_rest_for_own3: quietly tobit for_restrictions i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo3: quietly tobit for_restrictions_nfo i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

* personal and social norms

eststo tobit_pnorm_pfo3: quietly tobit index_personalnorm i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_pfo3: quietly tobit index_socialnorm i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

*social preferences

quietly probit soc_type_spiteful i.treat base_ihs_food_cons i.enumerator $controls  [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_spiteful3_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly probit soc_type_generous i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_generous3_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly probit soc_type_egalitarian i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc_egali3_pfo: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

* Write Regression Tables

* forest use restrictions
quietly esttab tobit_for_rest_for_own tobit_for_rest_for_own2 tobit_for_rest_for_own3   using "SI/Tables/tobit_rob_for_restrict.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Forest use restrictions index - Forest owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_for_rest_nfo tobit_for_rest_nfo2 tobit_for_rest_nfo3  using "SI/Tables/tobit_rob_for_restrict_nfo.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Forest use restrictions index - Non-forest owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

* Norms
quietly esttab tobit_pnorm_pfo tobit_pnorm_pfo2 tobit_pnorm_pfo3 using "SI/Tables/tobit_rob_pnorm.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Personal Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_snorm_pfo tobit_snorm_pfo2 tobit_snorm_pfo3 using "SI/Tables/tobit_rob_snorm.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Social Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") star(* 0.10 ** 0.05 *** 0.01) replace 


*Social preferences
quietly esttab probit_soc_spiteful_pfo probit_soc_spiteful2_pfo probit_soc_spiteful3_pfo using "SI/Tables/probit_rob_soc_spiteful.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Probit Model Marginal Effects - Spiteful Social Preferences") nobase stats(N N_clust r2_p chi2 p, labels("N" "Clusters" "Pseudo R2" " Chi2 Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Probit models reported as marginal effects.") replace 

quietly esttab probit_soc_generous_pfo probit_soc_generous2_pfo probit_soc_generous3_pfo using "SI/Tables/probit_rob_soc_generous.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Probit Model Marginal Effects - Generous Social Preferences") nobase stats(N N_clust r2_p chi2 p, labels("N" "Clusters" "Pseudo R2" " Chi2 Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Probit models reported as marginal effects.") replace 

quietly esttab probit_soc_egali_pfo probit_soc_egali2_pfo probit_soc_egali3_pfo using "SI/Tables/probit_rob_soc_egalitarian.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Robustness Checks - Probit Model Marginal Effects - Egalitarian Social Preferences") nobase stats(N N_clust r2_p chi2 p, labels("N" "Clusters" "Pseudo R2" " Chi2 Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Probit models reported as marginal effects.") replace 


* Multinomial Logit Models for Social Preferences

* generate new variable that combines weak and strong types
recode soc_type (1=2 "Egalitarian") (2=2) (3=3 "Generous") (4=3) (5=4 "Spiteful") (6=1 "Unclassified"), gen (soc_type2) 
la var soc_type2 "Behavioral Types"

* run multinomial logit
eststo mlogit_soc: qui mlogit soc_type2 i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) baseoutcome(1) 
esttab mlogit_soc using "SI/Tables/mlogit_soc.tex", l b(3) ci(3) indicate("Enumerator FE = *.enumerator") drop(*.base_subcounty 0.treat) unstack noomitted title("Regression Results - Multinomial Logit Social Preference Types (base category: unclassified)") addnotes("Stratification variables abbreviated with (strat.). The model includes subcounty fixed effects." "Standard errors are clustered at the village level. ") replace

* Compute preditctive margins by treatment status
margins treat [pweight=inv_prob_allland], predict(outcome(1)) contrast(effects) post 
eststo mlogit_margin1, title(Unclassified)
estimates restore mlogit_soc
margins treat [pweight=inv_prob_allland], predict(outcome(2)) contrast(effects) post 
eststo mlogit_margin2, title(Egalitarian)
estimates restore mlogit_soc
margins treat [pweight=inv_prob_allland], predict(outcome(3)) contrast(effects) post 
eststo mlogit_margin3, title(Generous)
estimates restore mlogit_soc
margins treat [pweight=inv_prob_allland], predict(outcome(4)) contrast(effects) post 
eststo mlogit_margin4, title(Spiteful)

esttab  mlogit_margin* using "SI/Tables/mlogit_soc_margins.tex", l ci(3) star(* 0.10 ** 0.05 *** 0.01) mtitles("Unclassfied" "Egalitarian" "Generous" "Spiteful") rename(c1 "p-value") noobs title("Contrasts of predictive margins between treatment and control for different social preference types") replace

* SES Analysis

tabout base_ass_ses_quant using "SI/Tables/ses_index_baseline.tex", replace style(tex) twidth(14) font(bold) sum npos(tufte) c(mean base_ass_hh_item_radio mean base_ass_hh_item_tv mean base_ass_hh_item_bicycle mean base_ass_hh_item_phone mean base_ass_hh_item_solar mean base_ass_hh_item_mbike mean base_ass_hh_item_car mean base_ass_floor_improved mean base_ass_roof_improved mean base_ass_wall_improved) f(2c) h1(Share of HHs that own) clab(Radio TV Bicycle Mobile_Phone Solar_System Motorbike Car Impr._Floor Impr._Roof Impr._Wall)

tabout end_ass_ses_quant using "SI/Tables/ses_index_endline.tex", replace style(tex) twidth(14) font(bold) sum npos(tufte) c(mean end_ass_hh_item_radio mean end_ass_hh_item_tv mean end_ass_hh_item_bicycle mean end_ass_hh_item_phone mean end_ass_hh_item_solar mean end_ass_hh_item_mbike mean end_ass_hh_item_car mean end_ass_floor_improved mean end_ass_roof_improved) f(2c) h1(Share of HHs that own) clab(Radio TV Bicycle Mobile_Phone Solar_System Motorbike Car Impr._Floor Impr._Roof)

tabout ass_ses_quant using "SI/Tables/ses_index.tex", replace style(tex) twidth(14) font(bold) sum npos(tufte) c(mean ass_hh_item_radio mean ass_hh_item_tv mean ass_hh_item_bicycle mean ass_hh_item_phone mean ass_hh_item_solar mean ass_hh_item_mbike mean ass_hh_item_car mean ass_floor_improved mean ass_roof_improved mean ass_wall_improved) f(2c) h1(Share of HHs that own) clab(Radio TV Bicycle Mobile_Phone Solar_System Motorbike Car Impr._Floor Impr._Roof Impr._Wall)

eststo ols_ses_end1: quietly reg end_ass_ses_index i.treat i.end_enum $controls [pweight=inv_prob_allland], vce(cluster village_code) 
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)
eststo ols_ses_end2: quietly reg end_ass_ses_index i.treat $controls [pweight=inv_prob_allland], vce(cluster village_code) 
qui testparm i.treat $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)
eststo ols_ses_end3: quietly reg end_ass_ses_index i.treat base_ihs_food_cons i.end_enum $controls [pweight=inv_prob_allland], vce(cluster village_code)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo ols_ses_1: quietly reg ass_ses_index i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) 
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)
eststo ols_ses_2: quietly reg ass_ses_index i.treat $controls [pweight=inv_prob_allland], vce(cluster village_code) 
qui testparm i.treat $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)
eststo ols_ses_3: quietly reg ass_ses_index i.treat base_ihs_food_cons i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
qui testparm i.treat base_ihs_food_cons i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

quietly esttab ols_ses_end1 ols_ses_end2 ols_ses_end3 using "SI/Tables/ols_end_ses.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Linear Regressions Models - DV:Asset Ownership Index at Endline") nobase stats(N N_clust r2 Falt p_value, labels("N" "Clusters" "R2" " F Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.end_enum") star(* 0.10 ** 0.05 *** 0.01) replace 

quietly esttab ols_ses_1 ols_ses_2 ols_ses_3 using "SI/Tables/ols_ses.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Linear Regression Models - DV:Asset Ownership Index at Follow-Up") nobase stats(N N_clust r2 Falt p_value, labels("N" "Clusters" "R2" " F Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) replace 


** Hetergenous treatment effect by wealth inequalities

* create gini coefficient for baseline wealth inequality

gen gini_land_base =.
levelsof village_code
ineqdec0 base_land_area [aweight=inv_prob_allland], by(village_code)
foreach z in `r(levels)'   {
replace gini_land_base=r(gini_`z') if village_code==`z'
}
la var gini_land_base "Gini land (village)"

egen base_ass_ses_sum = rowtotal(base_ass_hh_item_* base_ass_floor_improved base_ass_roof_improved base_ass_wall_improved) 
gen gini_ass_base =.
levelsof village_code
ineqdec0 base_ass_ses_sum [aweight=inv_prob_allland], by(village_code)
foreach z in `r(levels)'   {
replace gini_ass_base=r(gini_`z') if village_code==`z'
}
la var gini_ass_base "Gini assets (village)"


* included wealth inequalities and interactions with treatment

global controls i.base_subcounty strat_base_num_PFOs_vil strat_base_inc_pc_vil strat_base_dist_road_vil strat_base_l1_area_vil

eststo tobit_for_rest_ineq1: quietly tobit for_restrictions i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_ineq2: quietly tobit for_restrictions i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_ineq3: quietly tobit for_restrictions i.treat i.enumerator gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_land_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_ineq4: quietly tobit for_restrictions i.treat i.enumerator gini_land_base i.treat#c.gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_land_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_ineq5: quietly tobit for_restrictions i.treat i.enumerator gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_ineq6: quietly tobit for_restrictions i.treat i.enumerator gini_ass_base i.treat#c.gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)


eststo tobit_for_rest_nfo_ineq1: quietly tobit for_restrictions_nfo i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo_ineq2: quietly tobit for_restrictions_nfo i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo_ineq3: quietly tobit for_restrictions_nfo i.treat i.enumerator gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_land_base $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo_ineq4: quietly tobit for_restrictions_nfo i.treat i.enumerator gini_land_base i.treat#c.gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_land_base $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

grstyle set color viridis, n(2) range(0.2,0.8)
margins treat, at(gini_land_base=(0 0.2 0.4 0.6 0.8))
marginsplot, recast(line) recastci(rarea) ciopt(color(%30)) legend(on) title("")
graph export  "SI/Figures/interaction_plot.pdf", replace



eststo tobit_for_rest_nfo_ineq5: quietly tobit for_restrictions_nfo i.treat i.enumerator gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo_ineq6: quietly tobit for_restrictions_nfo i.treat i.enumerator gini_ass_base i.treat#c.gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_ass_base $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)



eststo tobit_pnorm_ineq1: quietly tobit index_personalnorm i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_pnorm_ineq2: quietly tobit index_personalnorm i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_pnorm_ineq3: quietly tobit index_personalnorm i.treat i.enumerator gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_land_base $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_pnorm_ineq4: quietly tobit index_personalnorm i.treat i.enumerator gini_land_base i.treat#c.gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_land_base $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_pnorm_ineq5: quietly tobit index_personalnorm i.treat i.enumerator gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator  gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_pnorm_ineq6: quietly tobit index_personalnorm i.treat i.enumerator gini_ass_base i.treat#c.gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)



eststo tobit_snorm_ineq1: quietly tobit index_socialnorm i.treat i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_ineq2: quietly tobit index_socialnorm i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.strat_base_dist_road_vil $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_ineq3: quietly tobit index_socialnorm i.treat i.enumerator gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_land_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_ineq4: quietly tobit index_socialnorm i.treat i.enumerator gini_land_base i.treat#c.gini_land_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_land_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_ineq5: quietly tobit index_socialnorm i.treat i.enumerator gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_ineq6: quietly tobit index_socialnorm i.treat i.enumerator gini_ass_base i.treat#c.gini_ass_base $controls [pweight=inv_prob_allland], vce(cluster village_code) ll(0) ul(1)
qui testparm i.treat i.enumerator i.treat#c.gini_ass_base $controls
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)


* Write Regression Tables

* forest use restrictions
quietly esttab tobit_for_rest_ineq1 tobit_for_rest_ineq2  using "SI/Tables/tobit_for_rest_ineq1.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Market Distance - Forest use restrictions index - Forest owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_for_rest_ineq3 tobit_for_rest_ineq4 tobit_for_rest_ineq5 tobit_for_rest_ineq6 using "SI/Tables/tobit_for_rest_ineq2.tex", l b(3) ci(3) drop(*.base_subcounty) order(*.treat str*) eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Inequality- Forest use restrictions index - Forest owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_for_rest_nfo_ineq1 tobit_for_rest_nfo_ineq2 using "SI/Tables/tobit_for_rest_NFO_ineq1.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Market Distance - Forest use restrictions index - Non-forest owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_for_rest_nfo_ineq3 tobit_for_rest_nfo_ineq4 tobit_for_rest_nfo_ineq5 tobit_for_rest_nfo_ineq6 using "SI/Tables/tobit_for_rest_NFO_ineq2.tex", l b(3) ci(3) drop(*.base_subcounty) order(*.treat str*) eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Inequality- Forest use restrictions index - Non-forest owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 


* Norms
quietly esttab tobit_pnorm_ineq1 tobit_pnorm_ineq2 using "SI/Tables/tobit_ineq_pnorm1.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Market Distance- Personal Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_pnorm_ineq3 tobit_pnorm_ineq4 tobit_pnorm_ineq5 tobit_pnorm_ineq6 using "SI/Tables/tobit_ineq_pnorm2.tex", l b(3) ci(3) drop(*.base_subcounty) order(*.treat str*)  eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Inequality - Personal Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 


quietly esttab tobit_snorm_ineq1 tobit_snorm_ineq2 using "SI/Tables/tobit_ineq_snorm1.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Market Distance - Social Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") star(* 0.10 ** 0.05 *** 0.01) replace 

quietly esttab tobit_snorm_ineq3 tobit_snorm_ineq4 tobit_snorm_ineq5 tobit_snorm_ineq6 using "SI/Tables/tobit_ineq_snorm2.tex", l b(3) ci(3) drop(*.base_subcounty) order(*.treat str*)  eqlabels(none) nomtitles title("Hetereogenous Treatment Effects Inequality - Social Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") star(* 0.10 ** 0.05 *** 0.01) replace 


******************************************************
** Correlation between Enrollment Rate and Outcomes **
******************************************************

* Create Dummy variable, 1 if above median PES enrollment at village level
egen vill_tag = tag(village_code)


gen base_vill_Ftakeup_treated = base_vill_Ftakeup 
replace base_vill_Ftakeup_treated = . if treat == 0

egen med = median(base_vill_Ftakeup_treated)

gen base_vill_Ftakeup_med = 0 if base_vill_Ftakeup < med
replace base_vill_Ftakeup_med = 1 if base_vill_Ftakeup >= med
replace base_vill_Ftakeup_med = . if treat == 0

la var base_vill_Ftakeup_med "Above median PES take-up"


* Run regressions
eststo tobit_for_rest_takeup: qui tobit for_restrictions i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code) ll(0) ul(1)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_for_rest_nfo_takeup: qui tobit for_restrictions_nfo i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code) ll(0) ul(1)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_pnorm_takeup: qui tobit index_personalnorm i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code) ll(0) ul(1)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

eststo tobit_snorm_takeup: qui tobit index_socialnorm i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code) ll(0) ul(1)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls 
estadd scalar p_value = r(p)
estadd scalar Falt = r(F)

qui probit soc_type_spiteful i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc1_takeup: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

qui probit soc_type_generous i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc2_takeup: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

qui probit soc_type_egalitarian i.base_vill_Ftakeup_med i.enumerator $controls [pweight=inv_prob_allland] if treat==1, vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.base_vill_Ftakeup_med i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_soc3_takeup: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

* Write results to latex tables
quietly esttab tobit_for_rest_takeup tobit_for_rest_nfo_takeup using "SI/Tables/tobit_for_rest_takeup.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) title("Correlation PES enrollment rate - Forest use restrictions index") mtitles("Forest Owners" "Non-forest Owners") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab tobit_pnorm_takeup tobit_snorm_takeup using "SI/Tables/tobit_norms_takeup.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) title("Correlation PES enrollment rate - Norms") mtitles("Personal Norms" "Social Norms") nobase stats(N N_clust r2_p Falt p_value, labels("N" "Clusters" "Pseudo R2" "F-Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Tobit models bounded between 0 and 1.") replace 

quietly esttab probit_soc1_takeup probit_soc2_takeup probit_soc3_takeup using "SI/Tables/probit_soc_takeup.tex", l b(3) ci(3) drop(*.base_subcounty) eqlabels(none) title("Correlation PES enrollment rate - Social preference types") mtitles("Spiteful" "Generous" "Egalitarian") nobase stats(N N_clust r2_p chi2 p, labels("N" "Clusters" "Pseudo R2" "Chi2 Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Probit models reported as marginal effects.") replace 


*******************
** Land Disputes **
*******************

* create balancing tables for land dispute variables

quietly iebaltab base_ldispute base_ldispute_* [pweight=inv_prob_allland], grpvar(treat) total fmissok rowvarlabels stdev texcolwidth("3cm") savetex("SI/Tables/land_disputes_baseline.tex") replace 

quietly iebaltab end_ldispute end_ldispute_* [pweight=inv_prob_allland], grpvar(treat) total fmissok rowvarlabels stdev texcolwidth("3cm") savetex("SI/Tables/land_disputes_endline.tex") replace 

quietly iebaltab ldispute ldispute_* [pweight=inv_prob_allland], grpvar(treat) total fmissok rowvarlabels stdev texcolwidth("3cm") savetex("SI/Tables/land_disputes_followup.tex") replace 


* regressions 

* endline
qui probit end_ldispute i.treat base_ldispute i.end_enum $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_ldispute_end1: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

qui probit end_ldispute_boundaries i.treat base_ldispute_boundaries i.end_enum $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_ldispute_end2: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

qui probit end_ldispute_trespassing i.treat base_ldispute_trespassing $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_ldispute_end3: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi


* follow-up
qui probit ldispute i.treat base_ldispute i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_ldispute_follup1: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

qui probit ldispute_boundaries i.treat base_ldispute_boundaries i.enumerator $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_ldispute_follup2: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

qui probit ldispute_trespassing i.treat base_ldispute_trespassing $controls [pweight=inv_prob_allland], vce(cluster village_code)
scalar Nclust = e(N_clust)
scalar r2p = e(r2_p)
qui testparm i.treat i.enumerator $controls
scalar p_value = r(p)
scalar chi = r(chi2)
eststo probit_ldispute_follup3: quietly margins, dydx(*) atmeans post
estadd scalar p=p_value
estadd scalar N_clust=Nclust
estadd scalar r2_p=r2p
estadd scalar chi2=chi

quietly esttab probit_ldispute_end1 probit_ldispute_end2 probit_ldispute_end3 using "SI/Tables/probit_ldispute_end.tex", l b(3) ci(3) drop(*.base_subcounty) order(*.treat base_* str*) eqlabels(none) title("Treatment Effect on Land Dispute Probability at Endline") mtitles("Overall" "Boundaries" "Trespassing") nobase stats(N N_clust r2_p chi2 p, labels("N" "Clusters" "Pseudo R2" "Chi2 Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.end_enum") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Probit models reported as marginal effects." "Model 3 does not include enumerator fixed effects, since this would reduce the sample size" "by 338 obsevations (no variation in outcomes for some enumerators).") replace 

quietly esttab probit_ldispute_follup1 probit_ldispute_follup2 probit_ldispute_follup3 using "SI/Tables/probit_ldispute_follup.tex", l b(3) ci(3) drop(*.base_subcounty) order(*.treat base_* str*) eqlabels(none) title("Treatment Effect on Land Dispute Probability at Follow-Up") mtitles("Overall" "Boundaries" "Trespassing") nobase stats(N N_clust r2_p chi2 p, labels("N" "Clusters" "Pseudo R2" "Chi2 Statistic" "p") f(%4.0f %4.0f %4.3f)) indicate("Enumerator FE = *.enumerator") star(* 0.10 ** 0.05 *** 0.01) addnotes("Stratification variables abbreviated with (strat.). All models include subcounty fixed effects." "Standard errors are clustered at the village level. Probit models reported as marginal effects." "Model 3 does not include enumerator fixed effects as marginal effects could not be estimated if included.") replace 
